package com.nhutcm.trackingthief.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class PrefUtils {

	public static void saveStringToPreference(Context context, String key,
			String value) {

		SharedPreferences sharedPref = PreferenceManager
				.getDefaultSharedPreferences(context);

		SharedPreferences.Editor editor = sharedPref.edit();

		editor.putString(key, value);
		editor.commit();

	}

	public static String readStringFromPreference(Context context, String key) {

		SharedPreferences sharedPref = PreferenceManager
				.getDefaultSharedPreferences(context);

		String value = sharedPref.getString(key, "");
		return value;
	}

	public static void saveBooleanToPreference(Context context, String key,
			boolean value) {
		SharedPreferences share = PreferenceManager
				.getDefaultSharedPreferences(context);
		share.edit().putBoolean(key, value).commit();
	}

	public static boolean readBooleanFromPreference(Context context, String key) {

		SharedPreferences sharedPref = PreferenceManager
				.getDefaultSharedPreferences(context);

		boolean value = sharedPref.getBoolean(key, false);
		return value;
	}
}
